@import '@/styles/utils.scss';

.mcpHubContainer {
  padding: 32px;
  background-color: #f8f9fa;
  min-height: 100vh;

  .loading, .error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    gap: 16px;
    color: #666;
  }

  .loading {
    .loadingSpinner {
      display: flex;
      justify-content: center;
      align-items: center;
      
      .spinner {
        width: 40px;
        height: 40px;
        border: 3px solid #f3f3f3;
        border-top: 3px solid #0066ff;
        border-radius: 50%;
        animation: spin 1s linear infinite;
      }
    }
  }

  @keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
  }

  .header {
    text-align: center;
    margin-bottom: 40px;

    h1 {
      font-size: 36px;
      font-weight: 700;
      margin-bottom: 12px;
      color: #1a1a1a;
      
      span {
        color: #0066ff;
        position: relative;
        
        &::after {
          content: '';
          position: absolute;
          bottom: -4px;
          left: 0;
          width: 100%;
          height: 2px;
          background: #0066ff;
          transform: scaleX(0);
          transition: transform 0.3s ease;
        }
        
        &:hover::after {
          transform: scaleX(1);
        }
      }
    }

    p {
      color: #666;
      font-size: 18px;
    }
  }

  .searchBar {
    width: 100%;
    max-width: 600px;
    margin: 0 auto 32px;
    position: relative;

    .searchIcon {
      position: absolute;
      left: 16px;
      top: 50%;
      transform: translateY(-50%);
      color: #666;
    }

    input {
      width: 100%;
      padding: 16px 16px 16px 48px;
      border: 2px solid #e0e0e0;
      border-radius: 12px;
      font-size: 16px;
      outline: none;
      transition: all 0.3s ease;
      background: white;

      &:focus {
        border-color: #0066ff;
        box-shadow: 0 0 0 4px rgba(0, 102, 255, 0.1);
      }

      &::placeholder {
        color: #999;
      }
    }
  }

  .filters {
    display: flex;
    gap: 20px;
    margin-bottom: 32px;
    flex-wrap: wrap;
    justify-content: center;

    .filterGroup {
      min-width: 200px;

      label {
        display: block;
        margin-bottom: 8px;
        color: #666;
        font-size: 14px;
        font-weight: 500;
      }

      select {
        width: 100%;
        padding: 12px;
        border: 2px solid #e0e0e0;
        border-radius: 8px;
        background-color: white;
        outline: none;
        transition: all 0.3s ease;
        cursor: pointer;
        appearance: none;
        background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
        background-repeat: no-repeat;
        background-position: right 12px center;
        background-size: 16px;
        padding-right: 40px;

        &:focus {
          border-color: #0066ff;
          box-shadow: 0 0 0 4px rgba(0, 102, 255, 0.1);
        }
      }
    }
  }

  .serverList {
    .listHeader {
      margin-bottom: 24px;
      
      h2 {
        font-size: 24px;
        color: #1a1a1a;
        font-weight: 600;
      }
    }

    .serverGrid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
      gap: 24px;
      
      .serverCard {
        background: white;
        border-radius: 16px;
        padding: 24px;
        transition: all 0.3s ease;
        border: 2px solid transparent;
        cursor: pointer;

        &:hover {
          transform: translateY(-4px);
          box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
        }

        &.active {
          border-color: #0066ff;
          box-shadow: 0 12px 24px rgba(0, 102, 255, 0.1);
        }

        .cardHeader {
          display: flex;
          align-items: center;
          gap: 16px;
          margin-bottom: 16px;
          justify-content: space-between;
          .headerText {
            display: flex;
            align-items: center;
            gap: 16px;
            margin-bottom: 16px;
            .iconPlaceholder {
              width: 48px;
              height: 48px;
              background: linear-gradient(135deg, #0066ff, #5c9dff);
              border-radius: 12px;
              display: flex;
              align-items: center;
              justify-content: center;
              color: white;
              font-size: 20px;
              font-weight: 600;
            }
  
            h3 {
              font-size: 20px;
              color: #1a1a1a;
              margin: 0;
            }
          }
          .githubLink {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            color: #6b7280;
            text-decoration: none;
            font-size: 13px;
            transition: all .2s ease;
            padding: 4px 8px;
            border-radius: 6px;
            background: #f3f4f6;
            align-self: flex-start;
          }
          .githubLink:hover {
            color: #111827;
            background: #e5e7eb
          }
        }

        .description {
          color: #666;
          margin-bottom: 20px;
          line-height: 1.5;
        }

        .tags {
          display: flex;
          gap: 8px;
          margin-bottom: 20px;
          flex-wrap: wrap;

          span {
            padding: 6px 12px;
            border-radius: 20px;
            font-size: 13px;
            font-weight: 500;

            &.configTag {
              background: #fff3e0;
              color: #f57c00;
            }

            &.githubTag {
              background: #e3f2fd;
              color: #1976d2;
            }

            &.serverNameTag {
              background: #e8f5e9;
              color: #388e3c;
            }
          }
        }

        .actions {
          display: flex;
          gap: 12px;

          button, a {
            padding: 10px 16px;
            border-radius: 8px;
            border: none;
            cursor: pointer;
            font-size: 14px;
            font-weight: 500;
            display: flex;
            align-items: center;
            gap: 8px;
            transition: all 0.2s ease;

            &.connect {
              background: #0066ff;
              color: white;
              flex: 1;

              &:hover {
                background: #0052cc;
              }
            }

            &.favorite {
              background: white;
              border: 2px solid #e0e0e0;
              color: #666;

              &:hover {
                border-color: #0066ff;
                color: #0066ff;
              }

              &.active {
                background: #0066ff;
                border-color: #0066ff;
                color: white;
              }
            }

            &.github {
              background: #24292e;
              color: white;
              text-decoration: none;

              &:hover {
                background: #1a1f24;
              }
            }
          }
        }

        .serverDetails {
          margin-top: 24px;
          padding-top: 24px;
          border-top: 1px solid #e0e0e0;

          h4 {
            font-size: 16px;
            color: #1a1a1a;
            margin-bottom: 16px;
          }

          .detailItem {
            margin-bottom: 12px;

            span {
              display: block;
              font-size: 14px;
              color: #666;
              margin-bottom: 4px;
            }

            code {
              display: block;
              background: #f5f7f9;
              padding: 12px;
              border-radius: 8px;
              font-family: 'Roboto Mono', monospace;
              font-size: 13px;
              color: #1a1a1a;
              overflow-x: auto;
              white-space: pre-wrap;
              word-break: break-all;
            }
          }
        }
      }
    }
  }
}
